<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
    * 实例的constructor指向构造函数
    * */
    function Perosn() {
        this.name = 'test';
        this.age = 20;
    }

    //通过new创建
    person1 = new Perosn();
    person2 = new Perosn();

    document.write(person1.constructor === Perosn)


    /*
    *
    * */

    //字面量创建对象
    let person3 = {
        name: "test",
        age: 20
    };

    //------------------//
    //为什么使用构造函数


    function PerosnThis() {
        this.name = 'test';
        this.age = 20;
        //return this
    }

    function PersonnThis1() {
        this.name = 'test';
        this.age = 20;
        //return {}
    }

    person4 = new PersonnThis1();

    document.write(person4.name);

    document.write(person4.constructor === PersonnThis1);


</script>
</body>
</html>